export default function (_, console) {
  console.save = function (data, filename) {
    if (!data) return

    if (!filename) filename = 'save.json'

    if (typeof data === 'object') {
      data = JSON.stringify(data, undefined, 2)
    }

    const blob = new Blob([data], { type: 'text/json' })

    const a = document.createElement('a')
    a.download = filename + '.json'
    a.href = URL.createObjectURL(blob)
    a.click()
  }
}
